﻿{include file="public/header"}

</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 消息管理
    <span class="c-gray en">&gt;</span> 消息列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>

<div class="page-container">
    <form method="get">
        <div class="ch-c">

            <div class="ch-form-select">
                <select name="already">
                    <option value="" >选择状态</option>
                    <option value="0" >已读</option>
                    <option value="1">未读</option>
                </select>

            </div>

            <button class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>

        </div>
    </form>
    <div style="display: flex">   <a class="ch-button ch-blue add"  href="javascript:;" title="新增">新增</a></div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort">
            <thead>
            <tr class="text-c">
                <th width="80">序号</th>
                <th width="80">类别</th>
                <th width="80">内容</th>
                <th width="80">店长</th>
                <th width="80">状态</th>
                <th width="50">操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name='list' id='vo'}
            <tr class="text-c">
                <td>{$vo.id}</td>
                <td>{$vo.types}</td>
                <td>{$vo.content}</td>
                <td>{$vo.username}</td>
                <td style="color: red">{$vo.already}</td>

                <td class="td-manage">
                    <a style="text-decoration:none" class="ml-5 tui button" data-id="{$vo.id}" href="javascript:;" title="推送"><span class="label label-primary">推送</span></a>
                    <a style="text-decoration:none" class="ml-5 edit button" data-id="{$vo.id}" href="javascript:;" title="编辑"><span class="label label-primary">编辑</span></a>
                    <a style="text-decoration:none" class="ml-5 del button" data-id="{$vo.id}" href="javascript:;" title="删除"><span class="label label-danger">删除</span></a>


                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <div class="pages" style="float: right">{$list->render()}</div>

    </div>
</div>

{include file="public/footer"}
<script type="text/javascript">
    /**
     * 添加消息
     */
    /**
     * 开工设置
     */
    $('.page-container').on('click','.add',function () {
        var winWidth = $(window).width();
        var areaWidth = "";
        var areaHeight = "";
        if( winWidth > 768 ){
            areaWidth = "500px"
            areaHeight = "350px"
        } else {
            areaWidth = '100%'
            areaHeight = '100%'
        }
        var src="{:Url('index/message/add')}";
        layer.open({
            type: 2,
            area: [areaWidth, areaHeight],
            fix: false,
            maxmin: true,
            shade: 0.4,
            title: '添加消息',
            content: src
        });

    });

    /**
     * 推送消息
     */
    $('.tui').click(function () {
        var id=$(this).attr('data-id');
        var obj={};
        obj.id=id;
        var src="{:Url('index/message/tui')}";
        layer.confirm('确定推送么？', function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (data) {
                    var res=JSON.parse(data);
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });
    /**
     * 删除
     */
    $('.del').click(function () {
        var id=$(this).attr('data-id');
        var obj={};
        obj.id=id;
        var src="{:Url('index/message/del')}";
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (data) {
                    var res=JSON.parse(data);
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });

        /**
         * 开工设置
         */
        $('.page-container').on('click','.edit',function () {
            var winWidth = $(window).width();
            var areaWidth = "";
            var areaHeight = "";
            if( winWidth > 768 ){
                areaWidth = "500px"
                areaHeight = "300px"
            } else {
                areaWidth = '100%'
                areaHeight = '100%'
            }
            var id = $(this).attr('data-id');
            var src="{:Url('index/message/edit')}";
            layer.open({
                type: 2,
                area: [areaWidth, areaHeight],
                fix: false,
                maxmin: true,
                shade: 0.4,
                title: '消息设置',
                content: src + '?store_id=' + id
            });

        });

</script>
</body>
</html>